home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK2.toast / Development Kits (Disc 2) / QuickDraw GX / Programming Stuff / Sample Code / Printing Samples / Extensions… / "kabooms" (global data info) ƒ / no kaboom ƒ / no kaboom.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-10  |  1.8 KB  |  96 lines  |  [TEXT/MPS ]

  1. /*    File: no kaboom.c
  2.     
  3.     C code for a simple printing extension.
  4.     
  5.     Dave Hersey
  6.     Apple Developer Technical Support
  7.  
  8.     2/01/93    - dmh - Created.
  9.     4/26/93    - dmh - Updated to use recommended approach,
  10.                     and work around b1 shutdown bug.
  11.     9/07/93 - dmh - Updated for b2.
  12.    12/18/93 - dmh - Updated for b3.
  13.     3/22/94 - dmh - Verified for b4.
  14. */
  15.  
  16. #include <Types.h>
  17. #include <Errors.h>
  18. #include <Resources.h>
  19. #include <ToolUtils.h>
  20. #include "Messages.h"
  21. #include "PrintingMessages.h"
  22.  
  23. // external defines for creating our A5 world.
  24.  
  25. extern long A5Size (void);
  26. extern void A5Init (void *);
  27.  
  28.  
  29. #define r_str        200
  30. #define r_s1_idx    1
  31. #define r_s2_idx    2
  32. #define r_s3_idx    3
  33. #define r_s4_idx    4
  34.  
  35. // globals
  36.  
  37. Str255    s1;
  38. Str255    s2;
  39. Str255    s3;
  40. Str255    s4;
  41.  
  42. // InitGlobalData is used to initialize any global data we need to
  43. // in our message override.  It's critical that you do things this
  44. // way, rather than access the data in the same scope that you call
  45. // NewMessageGlobals.  Otherwise, some compilers will generate code
  46. // with invalid data references.
  47.  
  48. OSErr InitGlobalData()
  49. {
  50.     short    oldResFile;
  51.  
  52. // Initialize any global data here.
  53.  
  54.     oldResFile = CurResFile();
  55.     UseResFile(GXGetMessageHandlerResFile());
  56.  
  57.     GetIndString(s1, r_str, r_s1_idx);
  58.     GetIndString(s2, r_str, r_s2_idx);
  59.     GetIndString(s3, r_str, r_s3_idx);
  60.     GetIndString(s4, r_str, r_s4_idx);
  61.  
  62.     UseResFile(oldResFile);
  63.     return ResError();
  64. }
  65.  
  66.  
  67. OSErr MyStartJob(StringPtr docName, long pageCount)
  68. {
  69.     OSErr    err1, err2;
  70.     
  71.     err1 = NewMessageGlobals(A5Size(), A5Init);
  72.     if (!err1) err1 = InitGlobalData();
  73.  
  74.     err2 = Forward_GXStartJob(docName, pageCount);
  75.  
  76.     if (!err2)
  77.         err2 = err1;
  78.  
  79.     if (err2)
  80.         DisposeMessageGlobals();
  81.  
  82.     return err2;
  83. }
  84.  
  85.  
  86. OSErr MyFinishJob()
  87. {
  88.     DebugStr(s1);
  89.     DebugStr(s2);
  90.     DebugStr(s3);
  91.     DebugStr(s4);
  92.     
  93.     DisposeMessageGlobals();
  94.     return Forward_GXFinishJob();
  95. }
  96.